validateEither

inline fun <ERR, A> A.validateEither(predicate: (A) -> Boolean, error: (A) -> ERR): Either<ERR, A>(source)

Given a predicate and an error generating function return either the original value in a Right if the predicate evaluates as true or the error as a Left.

eg: "hi mum".validate({it.contains("hi")},{"where's your manners?"})